from rest_framework.permissions import BasePermission

class HasProjectAPIKey(BasePermission):
    """
    允许通过项目 API Key 认证的请求
    """
    
    def has_permission(self, request, view):
        # 检查是否有项目信息（由 ProjectAPIKeyAuthentication 设置）
        return hasattr(request, 'project') and request.project is not None